home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / CMPLTPAS / FLUSHKEY.PAS < prev    next >
Pascal/Delphi Source File  |  1988-07-14  |  1KB  |  31 lines

  1. {->>>>FlushKey<<<<---------------------------------------------}
  2. {                                                              }
  3. { Filename: FLUSHKEY.SRC -- Last modified 7/11/88              }
  4. {                                                              }
  5. { This routine uses ROM BIOS services to flush waiting         }
  6. { characters from the keyboard buffer.  This should be done    }
  7. { immediately before user prompts which must NOT be answerable }
  8. { via type-ahead:  Go-aheads for file erasures, things like    }
  9. { that.                                                        }
  10. {                                                              }
  11. {     From: COMPLETE TURBO PASCAL 5.0  by Jeff Duntemann       }
  12. {    Scott, Foresman & Co., Inc. 1988   ISBN 0-673-38355-5     }
  13. {--------------------------------------------------------------}
  14.  
  15. PROCEDURE FlushKey;
  16.  
  17. VAR
  18.   Regs : Registers;  { USES DOS unit! }
  19.  
  20. BEGIN
  21.   Regs.AH := $01;            { AH=1: Check for keystroke }
  22.   Intr($16,Regs);            { Interrupt $16: Keyboard services}
  23.   IF (Regs.Flags AND $0040) = 0 THEN  { If chars in buffer }
  24.     REPEAT
  25.       Regs.AH := 0;          { Char is ready; go read it... }
  26.       Intr($16,Regs);        { ...using AH = 0: Read Char }
  27.       Regs.AH := $01;        { Check for another keystroke... }
  28.       Intr($16,Regs);        { ...using AH = 1 }
  29.     UNTIL (Regs.Flags AND $0040) <> 0;
  30. END;
  31.